package com.enjoyor.soa.traffic.rest.efoms.dubbo.impl;

import com.alibaba.dubbo.config.annotation.Reference;
import com.enjoyor.soa.traffic.api.dto.efoms.EvalItemInfoDto;
import com.enjoyor.soa.traffic.api.service.dubbo.efoms.IDubboEvalItemInfoService;
import com.enjoyor.soa.traffic.rest.efoms.dubbo.IEvalItemConsumeService;
import com.enjoyor.soa.traffic.util.enums.EnumAppCode;
import com.enjoyor.soa.traffic.util.helper.ResultHelper;
import com.enjoyor.soa.traffic.util.pojo.ResultPojo;
import org.springframework.stereotype.Component;

@Component
public class EvalItemConsumeService implements IEvalItemConsumeService {

//    @Reference
	@Reference(version = "1.0.0",timeout = 10000)
    private IDubboEvalItemInfoService dubboEvalItemInfoService;

    /**
     * 新增评价项
     *
     * @param evalItemInfoDto
     * @param username
     */
    @Override
    public ResultPojo insertEvalItemInfo(EvalItemInfoDto evalItemInfoDto, String username) {
        ResultPojo resultPojo;
        try {
            resultPojo = dubboEvalItemInfoService.insertEvalItemInfo(evalItemInfoDto,username);
        }catch (Exception e ){
            e.printStackTrace();
            return ResultHelper.getResult(e,EnumAppCode.OPERATOR_FAILURE);
        }
        return resultPojo;
    }

    /**
     * 修改评价项
     *
     * @param evalItemInfoDto
     * @param username
     */
    @Override
    public ResultPojo updateEvalItemInfo(EvalItemInfoDto evalItemInfoDto, String username) {
        ResultPojo resultPojo;
        try {
            resultPojo = dubboEvalItemInfoService.updateEvalItemInfo(evalItemInfoDto,username);
        }catch (Exception e ){
            e.printStackTrace();
            return ResultHelper.getResult(e,EnumAppCode.OPERATOR_FAILURE);
        }
        return resultPojo;
    }

    /**
     * 删除评价项
     *
     * @param evalItemId
     * @param username
     */
    @Override
    public ResultPojo deleteEvalItemInfo(String evalItemId, String username) {
        ResultPojo resultPojo;
        try {
            resultPojo = dubboEvalItemInfoService.deleteEvalItemInfo(evalItemId,username);
        }catch (Exception e ){
            e.printStackTrace();
            return ResultHelper.getResult(e,EnumAppCode.OPERATOR_FAILURE);
        }
        return resultPojo;
    }

    /**
     * 查询评价项
     *
     * @param evalItemId
     * @return
     */
    @Override
    public ResultPojo getEvalItemList(String evalItemId) {
        ResultPojo resultPojo;
        try {
            resultPojo = dubboEvalItemInfoService.getEvalItemList(evalItemId);
        }catch (Exception e ){
            e.printStackTrace();
            return ResultHelper.getResult(e,EnumAppCode.OPERATOR_FAILURE);
        }
        return resultPojo;
    }
}
